<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>自定义组件的v-model</h1>
    <p>相当于子组件有一个value的props</p>
    <p>子组件触发了@input事件</p>
    <template id="temp">
        <div>
           <button @click="handleClick">点击我</button>
        </div>
    </template>
    <main id="app">
        <p>父组件值： {{value}}</p>
        <my-com :fun1="handleInc"></my-com>
    </main>
</body>
<script src="../vue.js "></script>
<script>
    new Vue({
        el: "#app",
        data() {

            let that = this;

            return {
                value: 0,
                handleInc: (v) => {
                    console.log("123")
                    this.value = v;
                }
            }
        },
        methods: {
            
        },
        components: {
            "my-com": {
                props: {
                    fun1: Function
                },
                methods: {
                    handleClick() {
                        this.fun1("天才");
                    }
                },
                template: "#temp"
            }
        }
    })
</script>

</html>